home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Languages / Masm V6.11 / SAMPLES / NTSAMPLE / NTDLL / CMAIN.C$ / CMAIN.bin
Encoding:
Text File  |  1993-08-17  |  2.2 KB  |  82 lines

  1. /*------------------------------------------------------------------------
  2.  
  3.  C main that calls asm dll 
  4.  
  5.  Passes: char, short, int, long using stdcall calling and naming convention.
  6.  
  7.  Returns: number of failures.
  8.  
  9. --------------------------------------------------------------------------*/
  10.  
  11.  
  12.  
  13.  
  14. #include <stdio.h>
  15. #include <windows.h>
  16.  
  17. BOOL __stdcall VSIntTest( char int1, int int2, short int3, long int4 );
  18.  
  19. BOOL __stdcall RSIntTest( char *int1, int *int2, short *int3, long *int4 );
  20.  
  21.  
  22. const bNegMax = -128;
  23. const iNegOne = -1;
  24. const suMax   = 32767;
  25. const lNegMax = -2147483647 - 1;   
  26.  
  27.  
  28. int main( void ) 
  29.  
  30.   char bVal1 = bNegMax;
  31.   int iVal2 = iNegOne;
  32.   short iVal3 = suMax;
  33.   long lVal4 = lNegMax;
  34.  
  35.   int cErrors = 0;                // count of errors/failed tests
  36.  
  37.  
  38. /* Call a function in the DLL passing various params by value.
  39.    Since the params were passed by value, the original value passed
  40.    shouldn't have changed, generate an error if they were. */
  41.  
  42.   
  43.   if (!VSIntTest(bVal1, iVal2, iVal3, lVal4)) {
  44.     printf("Failed: Passing signed integers by value, stdcall, to MASM DLL.\n");
  45.     cErrors++;
  46.   }
  47.   else {
  48.     if (!( (bVal1 == bNegMax) && (iVal2 == iNegOne) && (iVal3 == suMax) && (lVal4 == lNegMax) )) {
  49.       printf("Stack corruption: signed integers by value, stdcall, to MASM DLL.\n");
  50.       cErrors++;
  51.     }
  52.     else {
  53.       printf("Passed: Passing signed integers by value, stdcall, to MASM DLL.\n");
  54.     }
  55.   }
  56.  
  57.  
  58.  
  59. /* Call another function in the DLL passing various params by reference.
  60.    Since the params were passed by reference, generate an error if they 
  61.    were not changed to the desired values within the DLL. */
  62.  
  63.  
  64.   if (!RSIntTest(&bVal1, &iVal2, &iVal3, &lVal4)) {
  65.     printf("Failed: Passing signed integers by reference, stdcall, to MASM DLL.\n");
  66.     cErrors++;
  67.   }
  68.   else {
  69.     if (!( (bVal1 == 1) && (iVal2 == 1) && (iVal3 == 1) && (lVal4 == 1) )) {
  70.       printf("Stack corruption: signed integers by reference, stdcall, to MASM DLL.\n");
  71.       cErrors++;
  72.     }
  73.     else 
  74.       printf("Passed: Passing signed integers by reference, stdcall, to MASM DLL.\n");
  75.   }
  76.   
  77.  
  78.   return cErrors;  // return a count of errors.
  79.  
  80. }
  81.